package mk.company.fin.utils;

import java.awt.Component;

import javax.swing.JList;
import javax.swing.plaf.basic.BasicComboBoxRenderer;

public class ComboBoxElementRenderer<E> extends BasicComboBoxRenderer {
	
	private static final long serialVersionUID = -5306983173253502575L;

	public Component getListCellRendererComponent(
            JList list, Object value, int index,
            boolean isSelected, boolean cellHasFocus)
        {
            super.getListCellRendererComponent(list, value, index,
                isSelected, cellHasFocus);

            if (value != null)
            {
                @SuppressWarnings("unchecked")
				ComboBoxElement<E> item = (ComboBoxElement<E>)value;
                setText( item.getValue() );
            }

//            if (index == -1)
//            {
//                ComboBoxElement item = (ComboBoxElement)value;
//                setText( "" + item.getKey());
//            }

            return this;
        }
}
